package afeng.run.jenkinsdemodeploy.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ShoppingCartAndOperate {

    @Autowired
    StringRedisTemplate stringRedisTemplate;

    @RequestMapping("redis")
    public String login() {
        return "jenkins我的购物车";
    }

    @RequestMapping("/hi")
    public String hello() {
        return "我要买电脑";
    }

    @RequestMapping("/c/{key}/{value}")
    public String add( @PathVariable("key") String key, @PathVariable("value") String value) {
        stringRedisTemplate.opsForValue().set(key, value);
        String hellow = stringRedisTemplate.opsForValue().get(key);
        return hellow;
    }
    @RequestMapping("/get/{value}")
    public String addi(@PathVariable("value") String value) {
        String hello = stringRedisTemplate.opsForValue().get(value);
        System.out.println("222");
        return hello;

    }
}